package com.syn.michat.mapper;

import com.syn.michat.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {

    public void add(User user);

    public List<User> findByUsername(String username);

    @Select("select * from t_user where username = #{username} and password = #{password}")
    @ResultMap("result")
    public User findByUser(String username, String password);

    @Select("select * from t_user where username = #{username}")
    @ResultMap("result")
    public User search(String username);

    @Select("select * from t_user where user_id = #{userId}")
    @ResultMap("result")
    public User findUser(String userId);

    @Update("update t_user set nickname = #{nickname} where username = #{username}")
    @ResultMap("result")
    public void updateNickname(String username, String nickname);
}
